

 getAjax_savecode();


function signature_ajax(){
    //alert("sign");
	$.ajax({
	    url: "../backend/authen!getWeixinSignInfo",
	    type: 'GET',
	    dataType: 'json',
	    //timeout: 1000,
	    cache: false,
	    async:false,
	    error: errFunction,
	    success:succFunction
	});
}


function errFunction(){
    //alert('获取signPackage失败');

    alert("网络请求失败，请重试！");
   /* signature_ajax();*/
}
        
function succFunction(data){
    var signature;
    var string;
    var url = data["url"];
    var str = JSON.stringify(data);  
    //alert(str);
    /*if(typeof(data["appId"])=="undefined" ||typeof(data["timestamp"])=="undefined"||typeof(data["nonceStr"])=="undefined"||typeof(data["signature"])=="undefined"){
         signature_ajax();
    }*/
    
	//console.log(data);
    //string = "jsapi_ticket="+data["ticket"]+"&noncestr="+data["nonceStr"]+"&timestamp="+data["timestamp"]+"&url="+data["url"]
    //signature = hex_sha1(string);
	//console.log(string);
   // alert(data["appId"]+'?'+data["timestamp"]+'?'+data["nonceStr"]+'?'+data["signature"]);
    wx.config({
    appId: data["appId"],
    timestamp: data["timestamp"],
    nonceStr: data["nonceStr"],
    signature:data["signature"],
    jsApiList: [
        'checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'onMenuShareQZone',
        'hideMenuItems',
        'showMenuItems',
        'hideAllNonBaseMenuItem',
        'showAllNonBaseMenuItem',
        'translateVoice',
        'startRecord',
        'stopRecord',
        'onVoiceRecordEnd',
        'playVoice',
        'onVoicePlayEnd',
        'pauseVoice',
        'stopVoice',
        'uploadVoice',
        'downloadVoice',
        'chooseImage',
        'previewImage',
        'uploadImage',
        'downloadImage',
        'getNetworkType',
        'openLocation',
        'getLocation',
        'hideOptionMenu',
        'showOptionMenu',
        'closeWindow',
        'scanQRCode',
        'chooseWXPay',
        'openProductSpecificView',
        'addCard',
        'chooseCard',
        'openCard'
    ]
    });
}

